package com.ywz.project.system.controller;

import com.ywz.common.ResultResp;
import com.ywz.project.system.dto.req.MenuPageReq;
import com.ywz.project.system.service.SysMenuApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 类描述 -> 系统菜单API
 *
 * @Author: ywz
 * @Date: 2024/10/27
 */
@Api(tags = "系统菜单API")
@RestController
@RequestMapping("/system/menu")
public class SysMenuApiController {
    @Resource
    private SysMenuApiService sysMenuApiService;

    /**
     * 方法描述 -> 获取菜单分页数据
     *
     * @param req 请求参数
     * @Author: ywz
     * @Date: 2024/11/05
     */
    @GetMapping("/getMenuPage")
    @ApiOperation("获取菜单分页数据")
    public ResultResp getMenuPage(MenuPageReq req) {
        return sysMenuApiService.getMenuPage(req);
    }

    /**
     * 方法描述 -> 获取菜单树
     *
     * @Author: ywz
     * @Date: 2024/11/13
     */
    @GetMapping("/getMenuTree")
    @ApiOperation("获取菜单树")
    public ResultResp getMenuTree() {
        return sysMenuApiService.getMenuTree();
    }

    @GetMapping("/getCurrentMenuTree")
    @ApiOperation(value = "获取当前用户菜单树", httpMethod = "GET")
    public ResultResp getCurrentMenuTree(){
        return sysMenuApiService.getCurrentMenuTree();
    }

    /**
     * 方法描述 -> 获取租户菜单列表
     *
     * @param key 租户key
     * @Author: ywz
     * @Date: 2024/11/20
     */
    @GetMapping("/getTenementMenuTree")
    @ApiOperation(value = "获取租户菜单树", httpMethod = "GET")
    public ResultResp getTenementMenuTree(String key){
        return sysMenuApiService.getTenementMenuTree(key);
    }

    @PostMapping("/saveMenu")
    @ApiOperation(value = "保存菜单", httpMethod = "POST")
    public ResultResp saveMenu(String json) {
        return sysMenuApiService.saveMenu(json);
    }
}
